package cn.itcast.order.config;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @author wanglichao
 */
@Configuration
public class MyConfiguration {
    @Bean
    /**负载均衡注解*/
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
    /**
     * 自定义负载均衡策略
     * 针对所有微服务都是随机轮询的
     */
    /*@Bean
    public IRule randomRule(){
        return new RandomRule();
    }*/
}
